import React, { Component } from 'react'
import { connect } from 'dva';
import { Button, message } from 'antd';

import ListItem from "@/components/ListCard";

import { KEYS } from '../enum'

interface Props {
  dispatch?: Function,
  details: {
    id: number,
    companyId: number
  },
  match: {
    params: {
      id: number
    }
  },
}

@connect(({ device_fire_monitor }) => ({
  details: device_fire_monitor.details || {}
}))
class Details extends Component<Props, any> {

  state = {
    data: [],
    hasMsg: null
  };

  componentWillMount() {
    this.state.hasMsg = message.loading('');
  }

  // componentDidMount() {
  //   const { dispatch, match } = this.props;
  //   const { params } = match;

  //   dispatch({
  //     type: 'device_fire_monitor/queryInfoById',
  //     payload: params.id
  //   }).then(() => {
  //     const { details } = this.props;
  //     const data = [];
  //     if(details) {
  //       KEYS.forEach(item => {
  //         data.push({
  //           name: item.name,
  //           value: details[item.key]
  //         })
  //       });
  //     }

  //     this.setState({ data })
  //   })
  // }

  render() {
    return (
      <>
        <ListItem data={ this.state.data }/>
        <div className="foo" style={{marginTop:'20px'}}>
          <Button onClick={ () => {
            window.history.back();
          } }>返回</Button>
        </div>
      </>
    );
  }
}

export default Details;


